package com.jiang.books.service;

import java.math.BigInteger;
import java.util.List;
import java.util.Set;

import javax.validation.ConstraintViolation;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import com.jiang.books.domain.Book;
import com.jiang.books.domain.BookSearchCriteria;

public interface BookService {
	
	final static String ALL_BOOK_NATIVE_QUERY =
			"select id, author_id, title, version from jiang_book";

	// Find all Books
	public List<Book> findAll();

    public Book findById(BigInteger id);
    public Book findByIdAndRevision(BigInteger id, int revision);
    public List<Book> findAuditById(BigInteger id);

	// Insert or update a Book	
	public Book save(Book book);
	
	// Delete a Book	
	public void delete(Book book);
	
	
	public List<Book> findByAuthorId(BigInteger authorId);
	public List<Book> findByAwardId(BigInteger awardId);
	
	
	// CrudRepository
	// Find Books by title
	public Book findByTitle(String title);
	
	public Page<Book> findAllByPage(Pageable pageable);	

	
	// Find all Books by native query
	public List<Book> findByNativeQuery(String query);
	
	// Find Books by criteria query
	public List<Book> findByCriteriaQuery(String title);
	public Page<Book> findByCriteria(BookSearchCriteria searchCriteria, Pageable pageable);
	
	public Set<ConstraintViolation<Book>> validateBook(Book book);
	
	
	// Test
	// Find all Books with Awards	
	public List<Book> findAllWithAwards();
	
}